//
//  TDatasource.m
//  RYDatasourceDemo
//
//   Copyright © 2016年 AC-英特路. All rights reserved.
//  Created by JiaKang.Zhong on 16/4/22.
//

#import "TDatasource.h"
#import "TCellOne.h"
#import "JGTableViewSectionModel.h"
#import "JGTableViewCellModel.h"
@implementation TDatasource

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    JGTableViewSectionModel * sectionModel = self.serverData[indexPath.section];
    JGTableViewCellModel * cellModel = sectionModel.cellItems[indexPath.row];
    TCellOne *cell = [tableView dequeueReusableCellWithIdentifier:cellModel.itemIdentifier
                                                            forIndexPath:indexPath];
    if (!cell) {
        cell = [[[NSBundle mainBundle] loadNibNamed:@"TCellOne" owner:nil options:nil] lastObject];
    }
    NSLog(@"测试 : %p",&cell);
    // 设置数据
    [cell configCellWithEntity:cellModel];
    return cell;
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 80.0;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    self.cellSelectedBlock(indexPath);
}

@end
